// pages/consult/zixun/saixuan/saixuan.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //地域信息
<<<<<<< HEAD
    region: ["北京市 北京市 东城区"],  
=======
    region: ["北京市","北京市","东城区"],  
>>>>>>> fenzhi
    // 擅长领域索引
    sindex: 0,
    //擅长领域
    clist: ["全部", "个人成长", "恋爱关系", "婚姻家庭", "亲子教育", "职场心理", "两性心理", "抑郁梳理", "情绪管理", "人际关系", "心理健康", "婆媳矛盾"],
    slist: [],
    //等级列表
    list: ["国家一级心理咨询师", "国家二级心理咨询师", "国家三级心理咨询师"],
    //等级索引
    aindex: 0,
    //等级列表展示页面
    show: false,
    //等级信息
    valueI: "国家一级心理咨询师",
    //性别信息
    sexlist: ["男", "女", "不限"],
    //性别索引
    sexindex: 0,
    //咨询方式
    findlist: ["全部方式", "视频咨询", "语音咨询"],
    //咨询索引
    findindex: 0,

  },
  onClickLeft(){
      wx.navigateBack()
  },
  getUserProvince(e) {
    this.setData({
      region: e.detail.value //将用户选择的省市区赋值给region
    })
  },
  selectItem(e) {
    const index = e.currentTarget.dataset.index;
    this.setData({
      sindex: index
    });
  },
  selectItemSex(e) {
    const index = e.currentTarget.dataset.index;
    this.setData({
      sexindex: index
    });
  },
  selectItemFind(e) {
    const index = e.currentTarget.dataset.index;
    this.setData({
      findindex: index
    });
  },
  showPopup() {
    this.setData({
      show: true
    });
  },
  onClose(option) {
    let e = option.currentTarget.dataset.index;
    if (e != undefined) {
      this.setData({
        aindex: e
      });
      console.log(this.data.aindex);
      this.setData({
        valueI: this.data.list[e]
      });
    };
    this.setData({
      show: false
    });
  },
  tijiao() {
<<<<<<< HEAD
    const region = this.data.region; //地域值
    const clistInfo = this.data.clist[this.data.sindex] === "全部" ? null : this.data.clist[this.data.sindex];//领域值
    const valueI = this.data.valueI; //等级值
    const sexlistInfo = this.data.sexlist[this.data.sexindex] === "不限" ? null : this.data.sexlist[this.data.sexindex];//性别值
    const findlistInfo = this.data.findlist[this.data.findindex] === "全部方式" ? null : this.data.findlist[this.data.findindex]; //咨询方式值

    const url = `/pages/consult/zixun/aftersaixuan/aftersaixuan?teacherAddress=${encodeURIComponent(region)}&fieldName=${encodeURIComponent(clistInfo)}&teacherGradeName=${encodeURIComponent(valueI)}&teacherSex=${encodeURIComponent(sexlistInfo)}&consultName=${encodeURIComponent(findlistInfo)}`;
=======
    const region = this.data.region[0] + "," +this.data.region[1] + "," + this.data.region[2];

    console.log("xiao:"+region);

    // console.log(region);
    const region0 = this.data.region[0];
    const region1 = this.data.region[1];
    const region2 = this.data.region[2]; //地域值
    const clistInfo = this.data.clist[this.data.sindex] === "全部" ? "" : this.data.clist[this.data.sindex];//领域值
    const valueI = this.data.valueI; //等级值
    const sexlistInfo = this.data.sexlist[this.data.sexindex] === "不限" ? "" : this.data.sexlist[this.data.sexindex];//性别值
    const findlistInfo = this.data.findlist[this.data.findindex] === "全部方式" ? "" : this.data.findlist[this.data.findindex]; //咨询方式值
    const url = `/pages/consult/zixun/aftersaixuan/aftersaixuan?teacherAddress=${region}&fieldName=${clistInfo}&teacherGradeName=${valueI}&teacherSex=${sexlistInfo}&moneyType=${findlistInfo}`
>>>>>>> fenzhi
    wx.navigateTo({ url });
  },
  chongzhi() {
    this.setData({
      region:["北京市","北京市","东城区"],
      findindex:0,
      sindex:0,
      aindex:0,
      sexindex:0,
      valueI: "国家一级心理咨询师"
    });
    console.log("重置完毕！");
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})